Graphics3D 800, 600, 32, 2


Const NUM_VALUES% = 4 Shl 20	; has to be a multiple of 4 => Here 131072

Global values0#[NUM_VALUES]
Global values1#[NUM_VALUES]

Global sse0%[NUM_VALUES/4]
Global sse1%[NUM_VALUES/4]


; ===== Init =====
For i=0 To NUM_VALUES-1
	values0[i] = Rand(1.0, 1000.0)
Next

For i=0 To NUM_VALUES/4-1
	sse0[i] = Float4Create();
	sse1[i] = Float4Create();
	
	Float4Set(sse0[i], values0[i*4+0], values0[i*4+1], values0[i*4+2], values0[i*4+3]);
	Float4Set(sse1[i], values1[i*4+0], values1[i*4+1], values1[i*4+2], values1[i*4+3]);
Next


;----------------------------
;----- Test square root -----
;----------------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	values0[i] = Sqr(values0[i])
Next
Print "sqrt classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Sqrt(sse0[i])
Next
Print "sqrt SSE : " + (MilliSecs() - timeStart) + " ms"
Print

;-------------------------
;----- Test addition -----
;-------------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	values0[i] = values0[i] + values1[1]
Next
Print "add classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Add(sse0[i], sse1[i])
Next
Print "add SSE : " + (MilliSecs() - timeStart) + " ms"
Print

;----------------------------
;----- Test subtraction -----
;----------------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	values0[i] = values0[i] - values1[1]
Next
Print "sub classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Sub(sse0[i], sse1[i])
Next
Print "sub SSE : " + (MilliSecs() - timeStart) + " ms"
Print

;-------------------------------
;----- Test multiplication -----
;-------------------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	values0[i] = values0[i] * values1[1]
	;Print values0[i]
Next
Print "mul classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Mul(sse0[i], sse1[i])
Next
Print "mul SSE : " + (MilliSecs() - timeStart) + " ms"
Print

;--------------------
;----- Test div -----
;--------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	values0[i] = values0[i] / values1[1]
Next
Print "div classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Div(sse0[i], sse1[i])
Next
Print "div SSE : " + (MilliSecs() - timeStart) + " ms"
Print

;--------------------
;----- Test min -----
;--------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	If( values0[i] > values1[1] ) values0[i] = values1[i]
Next
Print "min classic : " + (MilliSecs() - timeStart) + " ms"

; === SSE ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Float4Min(sse0[i], sse1[i])
Next
Print "min SSE : " + (MilliSecs() - timeStart) + " ms"
Print

; === bbA ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Min(sse0[i], sse1[i])
Next
Print "min bbA : " + (MilliSecs() - timeStart) + " ms"
Print

;--------------------
;----- Test max -----
;--------------------

; === Classic ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES-1
	If( values0[i] < values1[1] ) values0[i] = values1[i]
Next
Print "max classic : " + (MilliSecs() - timeStart)

; === bbA ===
timeStart% = MilliSecs()
For i=0 To NUM_VALUES/4-1
	Max(sse0[i], sse1[i])
Next
Print "max bbA : " + (MilliSecs() - timeStart) + " ms"
Print



; ===== Clean =====
For i=0 To NUM_VALUES/4-1
	Float4Free(sse0[i]);
	Float4Free(sse1[i]);
Next


WaitKey()
;~IDEal Editor Parameters:
;~C#Blitz3D